package com.university.report.cmn.handler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import us.codecraft.webmagic.Spider;

/**
 * @ClassName health_report
 * @Author Jinondo
 * @Date 2021/6/20 21:41
 */
@Component
@Slf4j
public class ImportantRegionTasks {

    @Autowired
    RedisTemplate redisTemplate3;

    @Scheduled(cron = "01 00 00 * * *")
    public void updateImportantRegion(){
        log.info("======= start update ImportantRegion =======");
        // 爬取开始
        Spider
                .create(new ImpRegionPageProcessor())
                .addPipeline(new ImpRegionPipeline(redisTemplate3))
                // 爬取的第一个页面
                .addUrl("http://m.bendibao.com/news/gelizhengce/fengxianmingdan.php")
                // 启用的线程数
                .thread(2).run();
    }

}
